package mailcommon.helpers;

public enum FunctionType {

    Registration,
    Login,
    Logout,
    SendLetter,
    LoadLetters,
    CheckNewLetters,
    ReadLetter,
    DeleteLetter,
    CreateFolder,
    RenameFolder,
    DeleteFolder,
    MoveLetter;

    @Override
    public String toString() {
        switch (this) {
            case CheckNewLetters:
                return "check";
            case CreateFolder:
                return "create folder";
            case DeleteFolder:
                return "del folder";
            case DeleteLetter:
                return "del letter";
            case LoadLetters:
                return "load";
            case Login:
                return "login";
            case Logout:
                return "logout";
            case MoveLetter:
                return "move letter";
            case Registration:
                return "reg";
            case RenameFolder:
                return "rename folder";
            case SendLetter:
                return "send";
            case ReadLetter:
                return "read";
            default:
                return "undefined";
        }
    }

    public String description() {
        switch (this) {
            case CheckNewLetters:
                return "Checks for unread letters. Shows only \"metadata\" of letters."
                        + "For read letter use command \"" + ReadLetter.toString() + "\"";
            case CreateFolder:
                return "";
            case DeleteFolder:
                return "";
            case DeleteLetter:
                return "";
            case LoadLetters:
                return "Load all letters sent for specified mail address."
                        + "Shows only \"metadata\" of letters."
                        + "For read letter use command \"" + ReadLetter.toString() + "\"";
            case Login:
                return "";
            case Logout:
                return "";
            case MoveLetter:
                return "";
            case ReadLetter:
                return "Show letter and mark this read.";
            case Registration:
                return "Registrate new mail user.";
            case RenameFolder:
                return "";
            case SendLetter:
                return "Creating and sent new letter.";
            default:
                return "";
        }
    }

    public static FunctionType parse(String func) {
        for (FunctionType f : FunctionType.values()) {
            if (func.equalsIgnoreCase(f.toString())) {
                return f;
            }
        }
        return null;
    }
}
